package com.pine.dbant.common.plugin.meta;

import lombok.Getter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author xiaoyuan
 * @create 2022/11/17
 **/
@Getter
public class DefaultMetadataNode implements MetadataNode {
    private String id;
    private String parentId;
    private String name;
    private String type;
    private List<MetadataNode> children;
    private Boolean leaf  = false;
    private Map<String,Object> properties = new HashMap<>();


    @Override
    public MetadataNode setId(String id) {
        this.id = id;
        return this;
    }

    @Override
    public MetadataNode setName(String name) {
        this.name = name;
        return this;
    }

    @Override
    public MetadataNode setType(String type) {
        this.type = type;
        return this;
    }



    @Override
    public MetadataNode addProperty(String key, Object value) {
        this.properties.put(key,value);
        return this;
    }

    @Override
    public MetadataNode addProperties(Map<String, Object> properties) {
        this.properties.putAll(properties);
        return this;
    }


    @Override
    public MetadataNode setParentId(String parentId) {
        this.parentId = parentId;
        return this;
    }

    @Override
    public MetadataNode setLeaf(Boolean leaf) {
        this.leaf = leaf;
        return this;
    }


    @Override
    public void setChildren(List<MetadataNode> list) {
       this.children = list;
    }
}
